package com.czy.controller;

import java.util.Date;

import javax.jms.Queue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//@Component
public class QueueProducer {

	@Autowired
	private JmsMessagingTemplate jmsMessagingTemplate;
	@Autowired
	private Queue queue;

	@SuppressWarnings("deprecation")
	public void produceMsg() {
		jmsMessagingTemplate.convertAndSend(queue, "message:" + new Date().toLocaleString());
	}
	
	
	@SuppressWarnings("deprecation")
	@Scheduled(fixedDelay = 3000)
    public void produceMsgScheduled(){
        jmsMessagingTemplate.convertAndSend(queue,"******Scheduled:"+ new Date().toLocaleString());
        System.out.println("发送消息。。。");
    }
}
